// pages/me/score/takePhone/list.js
const { toUrl,globalData } = getApp();
import { request } from "@/utils/request";
Page({
  /**
   * 页面的初始数据
   */
  toUrl,
  data: {
    globalData,
    pages: 1,
    count: 1,
    loading: '下拉加载更多',
    dataList:[],
    showtip: false
  },
  getDetail() {
    if(this.data.pages > this.data.count) {
      return
    }
    const that = this
    let data = {
      page: this.data.pages,
    };
    request("user/report_list", { data }).then((res) => {
       res.data.map((it)=>{
        it.images = it.images[0]
      })
        that.setData({
            dataList: that.data.dataList.concat(res.data),
            count: res.count,
            pages: ++that.data.pages
        })
        if(that.data.dataList.length > 0) {
          that.setData({
            showtip: false
          })
        }else {
          that.setData({
            showtip: true
          })
        }
        if(that.data.pages > that.data.count) {
          that.setData({
            loading: '加载完毕'
          })
        }
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getDetail();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if(this.data.pages > this.data.count) {
      return
    }else {
      this.getDetail()
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
});
